package test.com.sky.tomcatUtil;

import org.apache.catalina.util.RequestUtil;

import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;

public class RequestUtilDemo {


    private static void parseParameterDemo (   ){

        // 实战 https://search.bilibili.com/all?keyword=%E8%8B%B1%E9%9B%84%E8%BF%9E2&from_source=webtop_search&spm_id_from=333.788
        String query="username=sky&password=123457&";

        Map<String, String[]> values = new HashMap<>();
        try {
            RequestUtil.parseParameters(values, query, "utf8");
            for (Map.Entry<String, String[]> entry : values.entrySet()) {
                System.out.println(entry.getKey() + ":" + entry.getValue()[0] + ";");
            }
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }

    }


    private static void decode (   ){
        String  path = "c:\\测试\\webApp" ;
        System.out.println("RequestUtil.URLDecode(path) = " + RequestUtil.URLDecode(path, StandardCharsets.UTF_8.name()));

    }


    public static void main(String[] args) {

        decode();

    }






}
